import React, { useState } from 'react';
import { View, Text, FlatList, StyleSheet } from 'react-native';

const MessageScreen = () => {
  const [messages, setMessages] = useState([
    { id: '1', content: 'Hello, this is a message', time: '2024-05-22 12:00:00' },
    { id: '2', content: 'Another message', time: '2024-05-22 12:05:00' },
    // 添加更多消息...
  ]);

  const renderItem = ({ item }) => (
    <View style={styles.messageContainer}>
      <Text style={styles.messageContent}>{item.content}</Text>
      <Text style={styles.messageTime}>{item.time}</Text>
    </View>
  );

  return (
    <FlatList
      data={messages}
      renderItem={renderItem}
      keyExtractor={item => item.id}
    />
  );
};

const styles = StyleSheet.create({
  messageContainer: {
    padding: 10,
    borderBottomWidth: 1,
    borderBottomColor: '#ccc',
  },
  messageContent: {
    fontSize: 16,
  },
  messageTime: {
    fontSize: 12,
    color: '#999',
  },
});

export default MessageScreen;
